<%@ tag language="java" pageEncoding="UTF-8"
	deferredSyntaxAllowedAsLiteral="false" trimDirectiveWhitespaces="true"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ attribute name="id" required="true" type="java.lang.String"
	description="唯一标识."%>
<%@ attribute name="ciName" required="false" type="java.lang.String"
	description=""%>
<%@ attribute name="customerIdControlId" required="false"
	type="java.lang.String" description="customerIdControlId"%>
<%@ attribute name="valueControlId" required="false"
	type="java.lang.String" description="值所保存控件的id。"%>
<%@ attribute name="afterSelected" required="false"
	type="java.lang.String" description=""%>
<span id="${id}CiIdMsg"></span>
<span class="normal-header"> <a class="nui-txt-link" 
	href="javascript:${id}.onclick();">选择资产库 </a> </span>
<script type="text/javascript">
    
	var ${id}={};
	
	${id}.formatCiName = function(rowObject) {
		return "<a href=\"javascript:isperp.openDialog({contentUrl:'configuration/ci/ciResumeView?id=" + rowObject.id + "'});\">" + rowObject.name + "</a>";
	}

	${id}.setCustomerCiValue = function(id, name) {
		if (id && name) {
			var msg = {
				id : id,
				name : name
			};
			var rs = ${id}.formatCiName(msg);
			$("#${valueControlId}").val(id);
			$("#${id}CiIdMsg").html(rs);
			$("#${id}Diglog").wijdialog("close");
		}
		
	}
	${id}.afterSelected = function(id, name) {
	 
		if (id && name) {
			var msg = {
				id : id,
				name : name
			};
			var rs = ${id}.formatCiName(msg);
			$("#assAssetId").val(id);
			$("#ciIdMsg").html(rs);
		}
	};
	
	${id}.onclick = function() {
		isperp.openDialog({
			id:"${id}Diglog",
			onThisWindow : true,
			title : "选择关联资产",
			windowSize : "normal",
			contentUrl : "tags/selector/customerCiEdit?ctId=${id}&afterSelected=${afterSelected}&customerId="+($("#customerIdControlId").val()||""),
			buttons : [ {
				text : "确定",
				"class" : "nui-mainbtn",
				click : function() {
					var $me = $(this);
					$me.find("iframe")[0].contentWindow.getSelectRow();
				}
			}, {
				text : "关闭",
				"class" : 'grey',
				click : function() {
					$(this).wijdialog("close");
				}
			} ]
		});

	} 
</script>